package com.socketest;



import java.net.ServerSocket;
import java.net.Socket;

public class ServeSockeTest {
    public static void main(String[] args) {
        try {
            ServerSocket server = null ;
            try {
                //创建ServerSocket对象，指定端口是
                server = new ServerSocket(8080);
                System.out.println("服务启动成功");
            } catch (Exception e) {
                System.out.println("服务器启动出错");
            }
            Socket socket = null;
            try {
                //调用ServerSocket的accept方法，可以接受客户端的请求
                socket = server.accept();
                System.out.println("链接socket成功");
                ServerThread st = new ServerThread(socket);
                st.start();//服务端接客户端数据

                //服务发数据


            } catch (Exception e) {
                e.printStackTrace();
            }
        }finally {
//            System.out.println("未知异常。。。");
        }
    }
}